import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:thinking/entity/_.dart';
import 'package:thinking/widget/_.dart';
import 'package:thinking/config/_.dart';
import 'package:thinking/utils/_.dart';

class SearchRecommendWidget extends StatelessWidget{

  final List<SearchRecommendEntity> searchRecommendList;
  final String title;
  final Function clickTopicItem;

  SearchRecommendWidget({required this.searchRecommendList,required this.title,required this.clickTopicItem});




  @override
  Widget build(BuildContext context) {
    return Panel(
        top: 10,
        bottom: 10,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(title,style: TextStyle(fontSize: 17,fontWeight:FontWeight.w600 )),
            Container(
              margin: EdgeInsets.only(top: 10),
              height: Screen.setHeight(100),
              child: GridView.builder(
                shrinkWrap: true,
                physics: BouncingScrollPhysics(),
                scrollDirection: Axis.horizontal,
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                    childAspectRatio: 0.5
                ),
                itemBuilder: (context,index){
                  return GestureDetector(
                    onTap: (){
                      clickTopicItem(searchRecommendList[index].searchRecommendTitle,);
                    },
                    child:Row(
                      children: [
                        Text('#'),
                        SizedBox(width: 6,),
                        Container(
                          width:Screen.setWidth(60) ,
                          child: Text(searchRecommendList[index].searchRecommendTitle!,overflow: TextOverflow.ellipsis,),
                        ),
                        SizedBox(width: 4,),
                        Container(
                          height: 12,
                          width: 12,
                          decoration: BoxDecoration(
                              color: Config.hotText[searchRecommendList[index].searchRecommendStatus!]['color'],
                              borderRadius: BorderRadius.all(Radius.circular(2))
                          ),
                          child: Center(
                            child: Text(Config.hotText[searchRecommendList[index].searchRecommendStatus!]['val'],style: TextStyle(color: Colors.white,fontSize:9),),
                          ),
                        )
                      ],
                    ),
                  );
                },
                itemCount: searchRecommendList.length,
              ),
            )
          ],
        ));
  }

}

